import { priority } from "utils/constants/definetypes"
import { generateUniqueId } from "utils/utils"

 

export default 
{
     
    creep:{
        scout(room:string,rooms:string[])
        {
            // creep.scout("E54S57",["E54S58"])
            const taskarg:ICreepTaskData<"scout">={
                type: "scout",
                arg: {
                    targets: rooms,
                    visits: []
                },
                creeps: [],
                body: {},
                income: -1,
                room:room,
                required: [
                    [['scout'], 1,1]
                ],
                cost: 0
            }
            const task:ITask<ICreepTaskData<"scout">> = {
                id:generateUniqueId(),
                priority:priority.B,
                ttl:5000,
                type:"creep",
                shard:0,
                data:taskarg,
            }
            if(Game.rooms[room].addNewTask(task))
            {

            }
        },
        claim(room:string,targetroom:string,portal:number,p:number=priority.A)
        {
            // creep.claim("E53S58","E45S59",0)
            const task:ITask<ICreepTaskData<"claim">>={
                id: `${targetroom}_claim`,
                priority:p,
                ttl:2000,
                type:"creep",
                data:{
                    type:"claim",
                    portal:portal,
                    arg:{
                        room:targetroom,
                        action:"claim",
                    },
                    creeps:[],
                    body:{},
                    income:-1,
                    room:targetroom,
                    cost: 1,
                    required:[
                        [["claimer"],1,1]
                    ],
                    bodyconfig:[{
                        Role:'claimer',
                        body:[[MOVE,1],[CLAIM,1]]
                    }]
                },
                shard: 1,
            }
            Game.rooms[room].addNewTask(task);
        },
        attackController(room:string,targetroom:string,portal:number=0,body:IBodyConfig={
            Role:"claimer",
            body:[[CLAIM,10],[MOVE,10]],
        },p:number=priority.D)
        {
            // creep.attackController("E48S15","E52S22",0)
            const task:ITask<ICreepTaskData<"claim">>={
                id: `${targetroom}_attackCtl`,
                priority:p,
                ttl:-1,
                type:"creep",
                data:{
                    type:"claim",
                    portal:portal,
                    arg:{
                        room:targetroom,
                        action:"attackController",
                    },
                    creeps:[],room:targetroom,
                    body:{},
                    bodyconfig:[body],
                    income:-1,
                    cost: 0,
                    required:[
                        [["claimer"],1,1]
                    ]
                },
                shard: 1,
            }
            Game.rooms[room].addNewTask(task);
        },
        build(room:string,targetroom:string,workamount:number=1,upgradeAmount:number=0,portal:number,p:number=priority.A)
        {
            
             // creep.build("E57S54","E59S53",0,2,0)
            const task:ITask<ICreepTaskData<"helpBuild">>={
                id: `${targetroom}_helpBuild`,
                priority:p,
                ttl:-1,
                type:"creep",
                data:{
                    room:targetroom,
                    type:"helpBuild",
                    portal:portal,
                    arg:{
                    },
                    creeps:[],
                    body:{},
                    income:-1,
                    cost: 0,
                    required:[
                        [["worker"],workamount,workamount],
                        [["helpWorker"],upgradeAmount,upgradeAmount]
                    ]
                },
                shard: 1,
            }
            Game.rooms[room].addNewTask(task);
        }
    }
}